import MetaUtils from "@/utils/MetaUtils";
import {
    areaMetas, checkboxMetas,
    dateMetas,
    drawerMetas, editFuncMetas,
    editLayoutMetas, editMetas, foreignMetas, foreignToManyMetas,
    formCommonMetas,
    inputMetas,
    labelMetas, mentionsMetas,
    modalBasicMetas,
    numberMetas,
    operaMetas,
    optionsDataMetas, passwordMetas, quoteMetas,
    rateMetas,
    selectMetas,
    sliderMetas,
    switchMetas
} from "@/metas/ComponentMetas";
import Utils from "@/utils/basic.utils";

const basicLabel = '基础配置', formLabel = "表单配置", layoutLabel = "布局配置", editLabel='编辑框配置'
const DrawerEditTabMetas = {
    basic: {label: basicLabel, metas: [...drawerMetas, ...editFuncMetas]},
    edit: {label: editLabel, metas: [...editLayoutMetas, ...editMetas]},
}
const ModalEditTabMetas = {
    basic: {label: basicLabel, metas: [...modalBasicMetas, ...editFuncMetas]},
    edit: {label: editLabel, metas: [...editLayoutMetas, ...editMetas]},
}

const LabelTabMetas = {
    basic: {label: basicLabel, metas: [...labelMetas]}
}

const TextTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...inputMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const PasswordTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...passwordMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SelectTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...selectMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const RadioTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const RateTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [ ...rateMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const DateTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...dateMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SwitchTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...switchMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const TextareaTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...areaMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const CheckboxTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...checkboxMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const NumberTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...numberMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const SliderTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...sliderMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const TreeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const UploadTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

const CascadeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}
const CompleteTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}
const MentionsTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...mentionsMetas, ...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}
const StreeTabMetas = {
    basic: {label: basicLabel, metas: [...formCommonMetas, ...optionsDataMetas]},
    form: {label: formLabel, metas: [...operaMetas]},
    // layout: {label: layoutLabel, metas: [...formLayoutMetas]},
}

// 一对一外键
const ForeignTabMetas = {
    basic: {label: basicLabel, metas: [...foreignMetas]},
    // form: {label: formLabel, metas: [...operaMetas]},
}

// 一对多外键
const ForeignToManyTabMetas = {
    basic: {label: basicLabel, metas: [...foreignToManyMetas]},
}
// 表引用
const QuoteTabMetas = {
    basic: {label: basicLabel, metas: [...quoteMetas]},
    // form: {label: formLabel, metas: [...operaMetas]},
}

const FormTabMetas = {
    TextTabMetas, NumberTabMetas, SelectTabMetas, LabelTabMetas
    , RadioTabMetas, CascadeTabMetas, CheckboxTabMetas, StreeTabMetas, ForeignToManyTabMetas
    , SliderTabMetas, UploadTabMetas, TreeTabMetas, TextareaTabMetas, SwitchTabMetas, MentionsTabMetas
    , DateTabMetas, RateTabMetas, PasswordTabMetas, ForeignTabMetas, QuoteTabMetas, CompleteTabMetas
}

/**
 *
 * @param type
 * @return {Object | null}
 */
function getFormTabMetas(type) {
    type = Utils.firstUpperCase(type) + 'TabMetas';
    let formTabMeta = FormTabMetas[type];
    if(null == formTabMeta) {
        throw new Error(`找不到类型[${type}]对应的TabMetas对象`)
    }
    return MetaUtils.cloneTabMetas(formTabMeta);
}

export {getFormTabMetas, DrawerEditTabMetas, FormTabMetas, ModalEditTabMetas}
